<html>
<head><meta charset="utf-8"><title>params used from promoted substs · t-compiler/wg-polymorphization · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/index.html">t-compiler/wg-polymorphization</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html">params used from promoted substs</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="206260096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206260096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206260096">(Aug 07 2020 at 14:02)</a>:</h4>
<p>Why does <code>test</code> consider <code>T</code> used here?</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#![feature(rustc_attrs)]</span><span class="w"></span>

<span class="cp">#[rustc_polymorphize_error]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">].</span><span class="n">iter</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="206260469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206260469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206260469">(Aug 07 2020 at 14:05)</a>:</h4>
<p>Of the top of my head, I’m surprised that it does.</p>



<a name="206260490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206260490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206260490">(Aug 07 2020 at 14:05)</a>:</h4>
<p>me too <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="206260748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206260748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206260748">(Aug 07 2020 at 14:08)</a>:</h4>
<p>It looks like we are overly careful with lifetimes?</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#![feature(rustc_attrs)]</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">hey</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="p">())</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="cp">#[rustc_polymorphize_error]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">hey</span><span class="p">(</span><span class="o">&amp;</span><span class="p">());</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="206261420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206261420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206261420">(Aug 07 2020 at 14:13)</a>:</h4>
<p><code>&amp;()</code> is promoted and so we get something like <code>_5 = const test::&lt;T&gt;::promoted[0]</code> and it looks at the substs of that.</p>



<a name="206261459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206261459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206261459">(Aug 07 2020 at 14:14)</a>:</h4>
<p>So we might need some handling of promoteds like we do closures?</p>



<a name="206261537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206261537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206261537">(Aug 07 2020 at 14:14)</a>:</h4>
<p>wait</p>



<a name="206261555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206261555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206261555">(Aug 07 2020 at 14:14)</a>:</h4>
<p>so we promote <code>[1, 2, 3]</code> here <span aria-label="shock" class="emoji emoji-1f628" role="img" title="shock">:shock:</span></p>



<a name="206261601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206261601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206261601">(Aug 07 2020 at 14:15)</a>:</h4>
<p>hmm, we probably do, considering that <code>iter</code> takes <code>&amp;[T]</code></p>



<a name="206261621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206261621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206261621">(Aug 07 2020 at 14:15)</a>:</h4>
<p>damn, promoteds are just too strong</p>



<a name="206261668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206261668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206261668">(Aug 07 2020 at 14:15)</a>:</h4>
<p>Unless you want to, I can put a quick patch up for this?</p>



<a name="206261818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206261818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206261818">(Aug 07 2020 at 14:16)</a>:</h4>
<p>go ahead. Will gladly review though</p>



<a name="206267210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267210">(Aug 07 2020 at 14:59)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> as far as I can tell, fixing this resolves <a href="https://github.com/rust-lang/rust/pull/75255#discussion_r467051386">this comment</a>, right?</p>



<a name="206267238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267238">(Aug 07 2020 at 14:59)</a>:</h4>
<p>(I've checked and there's only one copy in the assembly after my fix)</p>



<a name="206267254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267254">(Aug 07 2020 at 14:59)</a>:</h4>
<p>(and two when I turn off polymorphisation)</p>



<a name="206267270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267270">(Aug 07 2020 at 14:59)</a>:</h4>
<p>did you also see <a href="https://github.com/rust-lang/rust/pull/75255#discussion_r467072757">https://github.com/rust-lang/rust/pull/75255#discussion_r467072757</a>?</p>



<a name="206267398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267398">(Aug 07 2020 at 15:00)</a>:</h4>
<p>Because I would be surprised if that's caused by promoteds</p>



<a name="206267485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267485">(Aug 07 2020 at 15:00)</a>:</h4>
<p>when you say <code>slice::Iter::map</code>, do you mean the <code>core::iter::traits::iterator::Iterator::map</code> function in the assembly that's highlighted when I click the link?</p>



<a name="206267533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267533">(Aug 07 2020 at 15:01)</a>:</h4>
<p>yeah</p>



<a name="206267543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267543">(Aug 07 2020 at 15:01)</a>:</h4>
<p>yeah, only one copy of that</p>



<a name="206267558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267558">(Aug 07 2020 at 15:01)</a>:</h4>
<p>that's what I meant initially</p>



<a name="206267618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267618">(Aug 07 2020 at 15:01)</a>:</h4>
<p>It was just that the function wasn't actually being polymorphised because of the promoteds, so there were two invocations still.</p>



<a name="206267805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267805">(Aug 07 2020 at 15:03)</a>:</h4>
<p>this is really surprising to me</p>



<a name="206267991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206267991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206267991">(Aug 07 2020 at 15:04)</a>:</h4>
<p><code>|_| ()</code> already considers <code>T</code> unused on nightly, so I don't understand why considering promoteds changed something here</p>



<a name="206268038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268038">(Aug 07 2020 at 15:04)</a>:</h4>
<p><span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="206268054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268054">(Aug 07 2020 at 15:04)</a>:</h4>
<p>You did test that example, did you?</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()];</span><span class="w"></span>
<span class="w">    </span><span class="n">x</span><span class="p">.</span><span class="n">iter</span><span class="p">().</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="n">_</span><span class="o">|</span><span class="w"> </span><span class="p">());</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">caller</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">test</span>::<span class="o">&lt;</span><span class="nb">String</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">test</span>::<span class="o">&lt;</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="nb">String</span><span class="o">&gt;&gt;</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="206268089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268089">(Aug 07 2020 at 15:05)</a>:</h4>
<p>The godbolt link is a slight adaptation of the example on github</p>



<a name="206268127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268127">(Aug 07 2020 at 15:05)</a>:</h4>
<p>in case you copied that one</p>



<a name="206268135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268135">(Aug 07 2020 at 15:05)</a>:</h4>
<p>I hadn't noticed that, will check it.</p>



<a name="206268326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268326">(Aug 07 2020 at 15:06)</a>:</h4>
<p>There are still two copies.</p>



<a name="206268332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268332">(Aug 07 2020 at 15:06)</a>:</h4>
<p><span aria-label="sad" class="emoji emoji-2639" role="img" title="sad">:sad:</span></p>



<a name="206268426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268426">(Aug 07 2020 at 15:07)</a>:</h4>
<p>I've still not figured out how your suggested change would change that either though.</p>



<a name="206268488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268488">(Aug 07 2020 at 15:08)</a>:</h4>
<p>There's something silly that I'm missing no doubt.</p>



<a name="206268519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268519">(Aug 07 2020 at 15:08)</a>:</h4>
<p>we can't polymorphize test but can polymorphize <code>|_| ()</code> here</p>



<a name="206268565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268565">(Aug 07 2020 at 15:08)</a>:</h4>
<p>while monomorphizing test, we polymorphize the instance of <code>map(|_| ())</code></p>



<a name="206268594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268594">(Aug 07 2020 at 15:09)</a>:</h4>
<p>rn <code>map</code> has no unused generic params itself, so we just early exit</p>



<a name="206268657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268657">(Aug 07 2020 at 15:09)</a>:</h4>
<p>if we try to polymorphize the substs of <code>map</code> we end up polymorphizing <code>|_| ()</code></p>



<a name="206268787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206268787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206268787">(Aug 07 2020 at 15:10)</a>:</h4>
<p>ah, I get it</p>



<a name="206269047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206269047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206269047">(Aug 07 2020 at 15:13)</a>:</h4>
<p>will make that change shortly, but the PR is still flawed because it doesn't fix every case of the problem it tries to (as per <a href="https://github.com/rust-lang/rust/pull/75255#discussion_r467061100">this comment</a>).</p>



<a name="206269504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206269504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206269504">(Aug 07 2020 at 15:15)</a>:</h4>
<p>Did you already test that flaw?</p>



<a name="206269618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206269618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206269618">(Aug 07 2020 at 15:16)</a>:</h4>
<p>I don't have a test for when <code>x</code> does use <code>f</code> (I was more focused on when it didn't, since that was the case that was making bootstrapping fail) - I've not tried it though.</p>



<a name="206269672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206269672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206269672">(Aug 07 2020 at 15:16)</a>:</h4>
<p>Because the situation you described shouldn't happen afaik</p>



<a name="206269728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206269728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206269728">(Aug 07 2020 at 15:17)</a>:</h4>
<p>As <code>x</code> considering <code>f</code> used would mean that <code>y</code> also considers <code>f</code> used, doesn't it?</p>



<a name="206269742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206269742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206269742">(Aug 07 2020 at 15:17)</a>:</h4>
<p>Because <code>y</code> uses <code>x</code></p>



<a name="206269773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206269773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206269773">(Aug 07 2020 at 15:17)</a>:</h4>
<p>actually, maybe you're right</p>



<a name="206269865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206269865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206269865">(Aug 07 2020 at 15:18)</a>:</h4>
<p>it's a good thing you're here to find my mistakes</p>



<a name="206270934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206270934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206270934">(Aug 07 2020 at 15:26)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> <a href="https://github.com/rust-lang/rust/issues/75260">#75260</a> for promoteds</p>



<a name="206274897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206274897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206274897">(Aug 07 2020 at 15:59)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> I'm not that familiar with how rustc's constant infrastructure works, should I just be ignoring all <code>ConstKind::Unevaluated</code> here (while still visiting in the <code>Some(promoted)</code> case)?</p>



<a name="206274926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206274926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206274926">(Aug 07 2020 at 15:59)</a>:</h4>
<p>Will there be some circumstance where I do care about the <code>substs</code> in it?</p>



<a name="206275035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206275035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206275035">(Aug 07 2020 at 16:00)</a>:</h4>
<p>Actually, re-reading your message, I assume I invoke <code>unused_generic_params</code> on the <code>DefId</code>?</p>



<a name="206275129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206275129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206275129">(Aug 07 2020 at 16:00)</a>:</h4>
<p>afaik you still have to deal with promoteds separately</p>



<a name="206275155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206275155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206275155">(Aug 07 2020 at 16:01)</a>:</h4>
<p>not sure, cc <span class="user-mention" data-user-id="124288">@oli</span> what's the <code>DefId</code> for promoted constants?</p>



<a name="206275203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206275203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206275203">(Aug 07 2020 at 16:01)</a>:</h4>
<p>is it just the <code>DefId</code> of the surrounding body?</p>



<a name="206279901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206279901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206279901">(Aug 07 2020 at 16:39)</a>:</h4>
<p>once both of these PRs land I would like to see another perf run <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> this should hopefully allow a lot more functions than before</p>



<a name="206339729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/params%20used%20from%20promoted%20substs/near/206339729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/params.20used.20from.20promoted.20substs.html#206339729">(Aug 08 2020 at 09:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/216091-t-compiler.2Fwg-polymorphization/topic/params.20used.20from.20promoted.20substs/near/206275203">said</a>:</p>
<blockquote>
<p>is it just the <code>DefId</code> of the surrounding body?</p>
</blockquote>
<p>yes</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>